<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        var arr = [
            [1, 2],
            [3, 4]
        ];


        // var arr2 = [];
        // arr.forEach(function (v) {
        //     arr2.push(v)
        // })

        // console.log(arr2);


        // var arr2 = arr.concat();





        // 二维数组的深拷贝
        var arr2 = [];

        for (var i = 0; i < arr.length; i++) {
            // arr[i]还是一个数组


            // 搞一个arr3  实现arr[i]是深拷贝
            var arr3 = [];
            for (var j = 0; j < arr[i].length; j++) {
                arr3.push(arr[i][j]);
            }


            arr2.push(arr3);
        }


        arr[0].push('a');

        console.log(arr2);

    </script>

</body>

</html>